package com.ss.android.newmedia.g;

import android.content.Context;
import android.location.Address;

import com.bytedance.article.common.a.g;
import com.bytedance.common.plugin.faces.CronetProxy;
import com.bytedance.frameworks.b.a.ComponentsManifest;
import com.bytedance.ttnet.bb;
import com.ss.android.common.applog.NetUtil;
import com.ss.android.common.location.LocationHelper;
import com.ss.android.common.util.MultiProcessSharedProvider;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.newmedia.BaseApplication;

import org.json.JSONObject;

import java.util.Iterator;
import java.util.Map;

public class aa implements bb {
    private static volatile aa a;

    public aa() {

    }

    public final int a(Context arg2, String arg3, int arg4) {
        return MultiProcessSharedProvider.getMultiProcessSharedPreference(arg2).getInt(arg3, arg4);
    }

    public final Context getContext() {
        return BaseApplication.getApplication();
    }

    public final Address a(Context arg2) {
        return LocationHelper.getInstance(arg2).loadSavedLocation();
    }

    public final String a(String arg2) throws Exception {
        return NetworkUtils.doGet(-1, arg2);
    }

    public final void a(Context arg2, String arg3, String arg4) {
        if (arg2 != null) {
            Object v0 = ComponentsManifest.findComponent(com.ss.android.aa.class);
            if (v0 != null) {
                ((com.ss.android.aa) v0).a(arg2, arg3, arg4);
            }
        }
    }

    public final void a(Context arg7, Map arg8) {
        try {
            com.ss.android.common.util.MultiProcessSharedProvider.a v2 = MultiProcessSharedProvider.a(arg7);
            Iterator v3 = arg8.entrySet().iterator();
            while (v3.hasNext()) {
                Object v0_1 = v3.next();
                Object v1 = ((Map.Entry) v0_1).getValue();
                if ((v1 instanceof Integer)) {
                    v2.a((String) ((Map.Entry) v0_1).getKey(), ((Integer) v1).intValue());
                    continue;
                }

                if ((v1 instanceof Long)) {
                    v2.a((String) ((Map.Entry) v0_1).getKey(), ((Long) v1).longValue());
                    continue;
                }

                if ((v1 instanceof Float)) {
                    v2.a((String) ((Map.Entry) v0_1).getKey(), ((Float) v1).floatValue());
                    continue;
                }

                if ((v1 instanceof Boolean)) {
                    v2.a((String) ((Map.Entry) v0_1).getKey(), ((Boolean) v1).booleanValue());
                    continue;
                }

                if (!(v1 instanceof String)) {
                    continue;
                }

                v2.a((String) ((Map.Entry) v0_1).getKey(), ((String) v1));
            }

            v2.a();
            return;
        } catch (Throwable v0) {
        }
    }

    public final void a(Context arg2, JSONObject arg3) {
        Object v0 = ComponentsManifest.findComponent(com.ss.android.aa.class);
        if (v0 != null) {
            ((com.ss.android.aa) v0).a(arg2, arg3);
        }
    }

    public final void a(String arg1, JSONObject arg2) {
        g.a(arg1, arg2);
    }

    public final String b(Context arg2, String arg3, String arg4) {
        return MultiProcessSharedProvider.getMultiProcessSharedPreference(arg2).getString(arg3, arg4);
    }

    public final boolean isCronetInstalled() {
        return CronetProxy.inst().getPlugin() != null;
    }

    public final int c() {
        return NetUtil.a();
    }

    public final String[] d() {
        return new String[]{"dm.toutiao.com", "dm.bytedance.com", "dm.pstatp.com"};
    }

    public final String e() {
        return ".snssdk.com";
    }

    public final String f() {
        return "ib";
    }

    public static aa getInstance() {
        if (aa.a == null) {
            Class v1 = aa.class;
            synchronized (v1) {
                if (aa.a == null) {
                    aa.a = new aa();
                }
            }
        }

        return a.a;
    }
}

